package com.zb.zbtcommon.controller;

import com.netflix.ribbon.proxy.annotation.Http;
import com.zb.zbtcommon.dto.ResponseEntity;
import com.zb.zbtcommon.entity.City;
import com.zb.zbtcommon.service.CityService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/zbt/common/city")
@Api(value = "CityControler分布城市控制器")
public class CityController {

    private Logger logger = LoggerFactory.getLogger(CityController.class);


    @Autowired
    private CityService cityService;
    @RequestMapping("/findcity")
    @ApiOperation("查询公司分布城市")

    public ResponseEntity<List<City>> findCity(){
        ResponseEntity entity=null;
        try {
            List<City> list = cityService.findCity();
           entity =new ResponseEntity();
            entity.setCode(HttpStatus.OK.value());
            entity.setTarget(list);
        } catch (Exception e) {
            logger.error("/zb/common/city/findcity     请求传值：无     异常信息"+e.getMessage());
            e.printStackTrace();
            entity.setCode(HttpStatus.INTERNAL_SERVER_ERROR.value());
            entity.setMessage("查询公司分布城市数据错误");
        }
        return  entity;
    }

}
